/**
 * @file   Student.cpp
 * @author xingyifan <xingyifan@xingyifan-VirtualBox>
 * @date   Thu Oct  1 13:52:02 2020
 * 
 * @brief   definition of Student,  mergesort and Heapsort, and functions of them
 * 
 * 
 */

#ifndef __STUDENT__STRUCTURE__
#define __STUDENT__STRUCTURE__

#include <iostream>
#include <vector>

class Student {
private:
    int std_no;   //student number
    char major;    //student major, M:math, P:physics, C:chemistry
    double GPA;    //GPA range:0~5
    
public:    
    Student();  //no use
    ~Student();  //no use
    int set(int _std_no, char _major, double  _GPA);  //get input
    int output(); //show it
    int get_std_no();  //same as name
    char get_major();  //same as name
    double get_GPA();  //same as name
    int set_GPA(double _GPA);  //same as name
};

int sort_m(Student *A, int n);   //sort with major
int arrange(Student *A, int n);   //sort with GPA

int Merge(Student *A, int p, int q, int r);  //Merge two array to one
int Merge_Sort(Student *A, int a, int b);  //divide and conquer
int Start_Merge(Student *A, int n);  //use it to Merge

int printout(Student *A, int n);  //print neatly

#define PARENT(i) (((i) + 1) >> 1 - 1) 
#define LEFTCHILD(i) (((i) + 1) << 1 - 1) 
#define RIGHTCHILD(i) (((i) + 1 ) << 1)

int Heap(Student *A, int n);  //bulid max Heap
int shiftdown(Student *A, int n, int i);  //shiftdown
int Heap_Sort(Student *A, int n);  //sort

#else
//Do nothing
#endif
